<?php
/**
 * --------------------------------
 * # 验证逻辑
 * --------------------------------
 * 1. 2020年9月14日22:44:06
 * 2. zhang
 * --------------------------------
 */
// 引入 JWT
use \Firebase\JWT\JWT;

$return_data['status'] = 0;
$return_data['info'] = '验证失败';

$token = $_REQUEST['token'];
// 增加偏差时间 单位：秒s
JWT::$leeway = 60;
try {
    $decoded = (array) JWT::decode($token, $jwt_key, array('HS256'));
} catch (\Throwable $e) {
    $return_data['info'] = isset($jwt_message[$e->getMessage()]) ? $jwt_message[$e -> getMessage()]: $jwt_message['default'];
    echo json_encode($return_data);
    exit();
}

// 获取用户信息
$current_user = $users[$decoded['user_id']];
if(empty($current_user)){
    echo json_encode($return_data);
    exit();
}
